<?php

namespace app\api\controller;

use app\BaseController;//测试专用
use  app\common\controller\DBase;
use think\facade\Db;
use app\api\logic\WebhookLogic;
use app\listing\logic\ShopifyListingLogic;
use Throwable;
use app\api\logic\ApiProductLogic;

class Webhook extends DBase
{
    /**
     * 模型
     * @var object
     * @phpstan-var ApiAdvaccountModel
     */

    public function initialize(): void
    {
        parent::initialize();
    }

    /**
     * @param $params
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @desc 创建订单
     * @author zhangheng
     */
    public function orders_create()
    {
        $params     = $this->request->post();
        $get     = $this->request->get();
        $params['shop_id'] = $get['shop_id'] ?? 0;
        $WebhookLogic = new WebhookLogic();
        return $WebhookLogic->orders_create($params);
    }
    /**
     * @param $params
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @desc 修改订单
     * @author zhangheng
     */
    public function orders_updated()
    {
        $params     = $this->request->post();
        $get     = $this->request->get();
        $params['shop_id'] = $get['shop_id'] ?? 0;
        $WebhookLogic = new WebhookLogic();
        return $WebhookLogic->orders_updated($params);
    }

    /**
     * @param $params
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @desc 创建订单
     * @author zhangheng
     */
    public function products_create()
    {
        $params            = $this->request->post();
        $get               = $this->request->get();
        $params['shop_id'] = $get['shop_id'] ?? 0;
        return  true;
       // return (new ShopifyListingLogic())->webhook_product_add($params);
    }

    /**
     * @param $params
     * @return \think\response\Json
     * @throws \think\db\exception\DbException
     * @desc 修改订单
     * @author zhangheng
     */
    public function products_updated()
    {
        $params     = $this->request->post();
        $get     = $this->request->get();
        $params['shop_id'] = $get['shop_id'] ?? 0;
        return  true;
       // return (new ShopifyListingLogic())->webhook_product_edit($params);
    }

    //获取订单
    public function order_add()
    {
        $params     = $this->request->post();
        $res        =  (new WebhookLogic())->orders_creates_consumer($params);
        return  $this->jsonMessage(201,false,'获取数据',$res);
    }
















}
